

 <?php 
 if($_SESSION['Permit']==1)
 { 
   
	  $sqluser =sprintf("select * from tbluser where id='%s'",$_GET['id']);
      $sqlsection =sprintf("select * from tblsection ");
 } 
 else 
 {
	 echo "ban không được Quyền Vào Đây";
	 exit;
 }
  $User=mysql_query($sqluser)or die(mysql_error());
  $Section=mysql_query($sqlsection)or die(mysql_error());
 
  
   
?>  
  <script type="text/javascript">
  
function enabledcontrol(control) {
	                   var e = document.getElementById('section_id');
	                 if(control.value==1)
					 {
						
							e.disabled = true;
						var i = 0;
						var n = e.options.length;
						for (i = 0; i < n; i++) {
							e.options[i].disabled = true;
							e.options[i].selected = false;
						}
					 }
					 else
					 {
						 e.disabled = false;
						var i = 0;
						var n = e.options.length;
						for (i = 0; i < n; i++) {
							e.options[i].disabled = false;
							e.options[i].selected = false;
						}
					 }
				}


  function submitt(control)
  {	  
    document.getElementById('temp').value=control.value;
	
	document.formEdit.submit();
  }
  function changevalue(control)
  {	  
     document.getElementById('url').value="article.php?id="+control.value;
  }
  </script>

<div style="font-size:16px;"> 

     <?php if(isset($_GET['id'])) $row=mysql_fetch_assoc($User);  ?>
  <fieldset style="width:90%;">
       
  <legend>Section Detail</legend>
  <form name="detailt" action="user/saveuser.php" method="POST">
  <p id="field"><span id="text">Tên Đăng Nhập </span> 
        <input name='id' type="hidden" value="<?php  echo $row['id']; ?>"/>
        <input name="username" type="text"  value="<?php if(isset($_GET['id'])) echo $row['username']; ?>" size="50" />
      </p>
    <p id="field"><span id="text">Email </span> 
         
        <input name="email" type="text"  value="<?php if(isset($_GET['id'])) echo $row['email']; ?>" size="50" />
      </p>
    <p id="field"><span id="text">Số Điện Thoại </span> 
          
        <input name="phone" type="text"  value="<?php if(isset($_GET['id'])) echo $row['phone']; ?>" size="50" />
      </p>
     <p id="field"><span id="text">Mức Quyền</span>
       <select name="permission"  onchange="enabledcontrol(this)">
         <option <?php if($row['permission']==1) echo "selected='selected'"  ?>  value="1">Full</option>
         <option <?php if($row['permission']==2) echo "selected='selected'" ?> value="2">Biên Tập</option>
       </select>
     </p>
     <p id="field"><span id="text">Chuyên mục quản lý</span>
       <?php 
	$araysection=explode(',',$row['section_ids']);
	  ?>
       <select name="selections[]" size="6" multiple="multiple" id="section_id"  <?php if($row['permission']==1) echo "disabled='disabled'" ?> >
               <?php 
								
						while ($rowitem=mysql_fetch_assoc($Section)){  
						?>
                           <option <?php 
		 foreach($araysection as $key) if($key==$rowitem['id']) echo "selected='selected'";		 
		  ?> value="<?php echo $rowitem['id']?>" ><?php echo $rowitem['name']?></option>
                           <?php		
						} 
						 
						?>
        </select>
             </p>
    <p id="field">    
       <label for="button">
         <input type="submit" name="click" value="<?php
	  if(isset($_GET['id']))
	    echo "Save";?>" />
       </label>
      </p>
  </form>
</fieldset>

</div>